home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / AIncludes / GXMath.a < prev    next >
Encoding:
Text File  |  1996-01-24  |  9.8 KB  |  591 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        GXMath.a
  3. ;
  4. ;    Contains:    QuickDraw GX math routine interfaces.
  5. ;
  6. ;    Version:    Technology:    Quickdraw GX 1.1
  7. ;                Package:    Universal Interfaces 2.2 in “MPW” on ETO #20
  8. ;
  9. ;    Copyright:    © 1984-1995 by Apple Computer, Inc.
  10. ;                All rights reserved.
  11. ;
  12. ;    Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13. ;                stack.  Include the file and version information (from above)
  14. ;                in the problem description and send to:
  15. ;                    Internet:    apple.bugs@applelink.apple.com
  16. ;                    AppleLink:    APPLE.BUGS
  17. ;
  18. ;
  19.  
  20.     IF &TYPE('__GXMATH__') = 'UNDEFINED' THEN
  21. __GXMATH__ SET 1
  22.  
  23.  
  24.     IF &TYPE('__CONDITIONALMACROS__') = 'UNDEFINED' THEN
  25.     include 'ConditionalMacros.a'
  26.     ENDIF
  27.  
  28.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  29.     include 'Types.a'
  30.     ENDIF
  31.  
  32.     IF &TYPE('__FIXMATH__') = 'UNDEFINED' THEN
  33.     include 'FixMath.a'
  34.     ENDIF
  35.     mathTypesIncludes: SET 1
  36. gxPoint                 RECORD    0
  37. x                         ds.l   1        ; offset: $0 (0)
  38. y                         ds.l   1        ; offset: $4 (4)
  39. sizeof                     EQU *            ; size:   $8 (8)
  40.                         ENDR
  41.  
  42. ; typedef struct gxPoint     gxPoint
  43. ; typedef unsigned short     gxColorValue
  44. gxPolar                 RECORD    0
  45. radius                     ds.l   1        ; offset: $0 (0)
  46. angle                     ds.l   1        ; offset: $4 (4)
  47. sizeof                     EQU *            ; size:   $8 (8)
  48.                         ENDR
  49.  
  50. gxMapping                 RECORD    0
  51. map                         ds.l   9        ; offset: $0 (0)
  52. sizeof                     EQU *            ; size:   $24 (36)
  53.                         ENDR
  54.  
  55. ; typedef struct gxPolar     gxPolar
  56. ; typedef struct gxMapping     gxMapping
  57.  
  58. gxColorValue1                    EQU        $0000FFFF            ; gxColorValue 1.0 
  59.  
  60. gxPositiveInfinity                EQU        $7FFFFFFF            ; for Fixed and Fract 
  61. gxNegativeInfinity                EQU        $80000000            ; for Fixed and Fract 
  62.  
  63.     mathRoutinesIncludes: SET 1
  64. ;
  65. ; gxMapping *CopyToMapping(gxMapping *target, const gxMapping *source)
  66. ;
  67.     IF ¬ GENERATINGCFM THEN
  68.         Macro
  69.         _CopyToMapping
  70.             move.w    #$31,d0
  71.             dc.w     $A832
  72.         EndM
  73.     ELSE
  74.         IMPORT_CFM_FUNCTION    CopyToMapping
  75.     ENDIF
  76.  
  77. ;
  78. ; gxMapping *InvertMapping(gxMapping *target, const gxMapping *source)
  79. ;
  80.     IF ¬ GENERATINGCFM THEN
  81.         Macro
  82.         _InvertMapping
  83.             move.w    #$32,d0
  84.             dc.w     $A832
  85.         EndM
  86.     ELSE
  87.         IMPORT_CFM_FUNCTION    InvertMapping
  88.     ENDIF
  89.  
  90. ;
  91. ; gxMapping *MapMapping(gxMapping *target, const gxMapping *source)
  92. ;
  93.     IF ¬ GENERATINGCFM THEN
  94.         Macro
  95.         _MapMapping
  96.             move.w    #$33,d0
  97.             dc.w     $A832
  98.         EndM
  99.     ELSE
  100.         IMPORT_CFM_FUNCTION    MapMapping
  101.     ENDIF
  102.  
  103. ;
  104. ; gxMapping *MoveMapping(gxMapping *target, Fixed hOffset, Fixed vOffset)
  105. ;
  106.     IF ¬ GENERATINGCFM THEN
  107.         Macro
  108.         _MoveMapping
  109.             move.w    #$34,d0
  110.             dc.w     $A832
  111.         EndM
  112.     ELSE
  113.         IMPORT_CFM_FUNCTION    MoveMapping
  114.     ENDIF
  115.  
  116. ;
  117. ; gxMapping *MoveMappingTo(gxMapping *target, Fixed hPosition, Fixed vPosition)
  118. ;
  119.     IF ¬ GENERATINGCFM THEN
  120.         Macro
  121.         _MoveMappingTo
  122.             move.w    #$35,d0
  123.             dc.w     $A832
  124.         EndM
  125.     ELSE
  126.         IMPORT_CFM_FUNCTION    MoveMappingTo
  127.     ENDIF
  128.  
  129. ;
  130. ; gxMapping *NormalizeMapping(gxMapping *target)
  131. ;
  132.     IF ¬ GENERATINGCFM THEN
  133.         Macro
  134.         _NormalizeMapping
  135.             move.w    #$36,d0
  136.             dc.w     $A832
  137.         EndM
  138.     ELSE
  139.         IMPORT_CFM_FUNCTION    NormalizeMapping
  140.     ENDIF
  141.  
  142. ;
  143. ; gxMapping *RotateMapping(gxMapping *target, Fixed angle, Fixed xCenter, Fixed yCenter)
  144. ;
  145.     IF ¬ GENERATINGCFM THEN
  146.         Macro
  147.         _RotateMapping
  148.             move.w    #$37,d0
  149.             dc.w     $A832
  150.         EndM
  151.     ELSE
  152.         IMPORT_CFM_FUNCTION    RotateMapping
  153.     ENDIF
  154.  
  155. ;
  156. ; gxMapping *ScaleMapping(gxMapping *target, Fixed hFactor, Fixed vFactor, Fixed xCenter, Fixed yCenter)
  157. ;
  158.     IF ¬ GENERATINGCFM THEN
  159.         Macro
  160.         _ScaleMapping
  161.             move.w    #$38,d0
  162.             dc.w     $A832
  163.         EndM
  164.     ELSE
  165.         IMPORT_CFM_FUNCTION    ScaleMapping
  166.     ENDIF
  167.  
  168. ;
  169. ; gxMapping *ResetMapping(gxMapping *target)
  170. ;
  171.     IF ¬ GENERATINGCFM THEN
  172.         Macro
  173.         _ResetMapping
  174.             move.w    #$39,d0
  175.             dc.w     $A832
  176.         EndM
  177.     ELSE
  178.         IMPORT_CFM_FUNCTION    ResetMapping
  179.     ENDIF
  180.  
  181. ;
  182. ; gxMapping *SkewMapping(gxMapping *target, Fixed skewX, Fixed skewY, Fixed xCenter, Fixed yCenter)
  183. ;
  184.     IF ¬ GENERATINGCFM THEN
  185.         Macro
  186.         _SkewMapping
  187.             move.w    #$3a,d0
  188.             dc.w     $A832
  189.         EndM
  190.     ELSE
  191.         IMPORT_CFM_FUNCTION    SkewMapping
  192.     ENDIF
  193.  
  194. ;
  195. ; void MapPoints(const gxMapping *source, long count, gxPoint vector[])
  196. ;
  197.     IF ¬ GENERATINGCFM THEN
  198.         Macro
  199.         _MapPoints
  200.             move.w    #$3b,d0
  201.             dc.w     $A832
  202.         EndM
  203.     ELSE
  204.         IMPORT_CFM_FUNCTION    MapPoints
  205.     ENDIF
  206.  
  207. ;
  208. ; short FirstBit(unsigned long x)
  209. ;
  210.     IF ¬ GENERATINGCFM THEN
  211.         Macro
  212.         _FirstBit
  213.             move.w    #$3c,d0
  214.             dc.w     $A832
  215.         EndM
  216.     ELSE
  217.         IMPORT_CFM_FUNCTION    FirstBit
  218.     ENDIF
  219.  
  220. ;
  221. ; short WideScale(const wide *source)
  222. ;
  223.     IF ¬ GENERATINGCFM THEN
  224.         Macro
  225.         _WideScale
  226.             move.w    #$3d,d0
  227.             dc.w     $A832
  228.         EndM
  229.     ELSE
  230.         IMPORT_CFM_FUNCTION    WideScale
  231.     ENDIF
  232.  
  233. ;
  234. ; short LinearRoot(Fixed first, Fixed last, Fract t[])
  235. ;
  236.     IF ¬ GENERATINGCFM THEN
  237.         Macro
  238.         _LinearRoot
  239.             move.w    #$3e,d0
  240.             dc.w     $A832
  241.         EndM
  242.     ELSE
  243.         IMPORT_CFM_FUNCTION    LinearRoot
  244.     ENDIF
  245.  
  246. ;
  247. ; short QuadraticRoot(Fixed first, Fixed control, Fixed last, Fract t[])
  248. ;
  249.     IF ¬ GENERATINGCFM THEN
  250.         Macro
  251.         _QuadraticRoot
  252.             move.w    #$3f,d0
  253.             dc.w     $A832
  254.         EndM
  255.     ELSE
  256.         IMPORT_CFM_FUNCTION    QuadraticRoot
  257.     ENDIF
  258.  
  259. ;
  260. ; gxPoint *PolarToPoint(const gxPolar *ra, gxPoint *xy)
  261. ;
  262.     IF ¬ GENERATINGCFM THEN
  263.         Macro
  264.         _PolarToPoint
  265.             move.w    #$40,d0
  266.             dc.w     $A832
  267.         EndM
  268.     ELSE
  269.         IMPORT_CFM_FUNCTION    PolarToPoint
  270.     ENDIF
  271.  
  272. ;
  273. ; gxPolar *PointToPolar(const gxPoint *xy, gxPolar *ra)
  274. ;
  275.     IF ¬ GENERATINGCFM THEN
  276.         Macro
  277.         _PointToPolar
  278.             move.w    #$41,d0
  279.             dc.w     $A832
  280.         EndM
  281.     ELSE
  282.         IMPORT_CFM_FUNCTION    PointToPolar
  283.     ENDIF
  284.  
  285. ;
  286. ; Fract FractCubeRoot(Fract source)
  287. ;
  288.     IF ¬ GENERATINGCFM THEN
  289.         Macro
  290.         _FractCubeRoot
  291.             move.w    #$42,d0
  292.             dc.w     $A832
  293.         EndM
  294.     ELSE
  295.         IMPORT_CFM_FUNCTION    FractCubeRoot
  296.     ENDIF
  297.  
  298. ;
  299. ; Fract FractDivide(Fract dividend, Fract divisor)
  300. ;
  301.     IF ¬ GENERATINGCFM THEN
  302.         Macro
  303.         _FractDivide
  304.             move.w    #$43,d0
  305.             dc.w     $A832
  306.         EndM
  307.     ELSE
  308.         IMPORT_CFM_FUNCTION    FractDivide
  309.     ENDIF
  310.  
  311. ;
  312. ; Fract FractMultiply(Fract multiplicand, Fract multiplier)
  313. ;
  314.     IF ¬ GENERATINGCFM THEN
  315.         Macro
  316.         _FractMultiply
  317.             move.w    #$44,d0
  318.             dc.w     $A832
  319.         EndM
  320.     ELSE
  321.         IMPORT_CFM_FUNCTION    FractMultiply
  322.     ENDIF
  323.  
  324. ;
  325. ; Fract FractSineCosine(Fixed degrees, Fract *cosine)
  326. ;
  327.     IF ¬ GENERATINGCFM THEN
  328.         Macro
  329.         _FractSineCosine
  330.             move.w    #$45,d0
  331.             dc.w     $A832
  332.         EndM
  333.     ELSE
  334.         IMPORT_CFM_FUNCTION    FractSineCosine
  335.     ENDIF
  336.  
  337. ;
  338. ; Fract FractSquareRoot(Fract source)
  339. ;
  340.     IF ¬ GENERATINGCFM THEN
  341.         Macro
  342.         _FractSquareRoot
  343.             move.w    #$46,d0
  344.             dc.w     $A832
  345.         EndM
  346.     ELSE
  347.         IMPORT_CFM_FUNCTION    FractSquareRoot
  348.     ENDIF
  349.  
  350. ;
  351. ; Fixed FixedDivide(Fixed dividend, Fixed divisor)
  352. ;
  353.     IF ¬ GENERATINGCFM THEN
  354.         Macro
  355.         _FixedDivide
  356.             move.w    #$47,d0
  357.             dc.w     $A832
  358.         EndM
  359.     ELSE
  360.         IMPORT_CFM_FUNCTION    FixedDivide
  361.     ENDIF
  362.  
  363. ;
  364. ; Fixed FixedMultiply(Fixed multiplicand, Fixed multiplier)
  365. ;
  366.     IF ¬ GENERATINGCFM THEN
  367.         Macro
  368.         _FixedMultiply
  369.             move.w    #$48,d0
  370.             dc.w     $A832
  371.         EndM
  372.     ELSE
  373.         IMPORT_CFM_FUNCTION    FixedMultiply
  374.     ENDIF
  375.  
  376. ; This next call is (source * multiplier / divisor) -- it avoids underflow, overflow by using wides 
  377. ;
  378. ; long MultiplyDivide(long source, long multiplier, long divisor)
  379. ;
  380.     IF ¬ GENERATINGCFM THEN
  381.         Macro
  382.         _MultiplyDivide
  383.             move.w    #$49,d0
  384.             dc.w     $A832
  385.         EndM
  386.     ELSE
  387.         IMPORT_CFM_FUNCTION    MultiplyDivide
  388.     ENDIF
  389.  
  390. ;
  391. ; unsigned long Magnitude(long deltaX, long deltaY)
  392. ;
  393.     IF ¬ GENERATINGCFM THEN
  394.         Macro
  395.         _Magnitude
  396.             move.w    #$4a,d0
  397.             dc.w     $A832
  398.         EndM
  399.     ELSE
  400.         IMPORT_CFM_FUNCTION    Magnitude
  401.     ENDIF
  402.  
  403. ;
  404. ; long VectorMultiplyDivide(long count, const long *vector1, long step1, const long *vector2, long step2, long divisor)
  405. ;
  406.     IF ¬ GENERATINGCFM THEN
  407.         Macro
  408.         _VectorMultiplyDivide
  409.             move.w    #$4b,d0
  410.             dc.w     $A832
  411.         EndM
  412.     ELSE
  413.         IMPORT_CFM_FUNCTION    VectorMultiplyDivide
  414.     ENDIF
  415.  
  416. ; wide operations are defined within FixMath.h only for PowerPC 
  417.     IF ¬ GENERATINGPOWERPC  THEN
  418. ;
  419. ; wide *WideAdd(wide *target, const wide *source)
  420. ;
  421.     IF ¬ GENERATINGCFM THEN
  422.         Macro
  423.         _WideAdd
  424.             move.w    #$4c,d0
  425.             dc.w     $A832
  426.         EndM
  427.     ELSE
  428.         IMPORT_CFM_FUNCTION    WideAdd
  429.     ENDIF
  430.  
  431. ;
  432. ; short WideCompare(const wide *target, const wide *source)
  433. ;
  434.     IF ¬ GENERATINGCFM THEN
  435.         Macro
  436.         _WideCompare
  437.             move.w    #$4d,d0
  438.             dc.w     $A832
  439.         EndM
  440.     ELSE
  441.         IMPORT_CFM_FUNCTION    WideCompare
  442.     ENDIF
  443.  
  444. ;
  445. ; wide *WideNegate(wide *target)
  446. ;
  447.     IF ¬ GENERATINGCFM THEN
  448.         Macro
  449.         _WideNegate
  450.             move.w    #$4e,d0
  451.             dc.w     $A832
  452.         EndM
  453.     ELSE
  454.         IMPORT_CFM_FUNCTION    WideNegate
  455.     ENDIF
  456.  
  457. ;
  458. ; wide *WideShift(wide *target, long shift)
  459. ;
  460.     IF ¬ GENERATINGCFM THEN
  461.         Macro
  462.         _WideShift
  463.             move.w    #$4f,d0
  464.             dc.w     $A832
  465.         EndM
  466.     ELSE
  467.         IMPORT_CFM_FUNCTION    WideShift
  468.     ENDIF
  469.  
  470. ;
  471. ; unsigned long WideSquareRoot(const wide *source)
  472. ;
  473.     IF ¬ GENERATINGCFM THEN
  474.         Macro
  475.         _WideSquareRoot
  476.             move.w    #$50,d0
  477.             dc.w     $A832
  478.         EndM
  479.     ELSE
  480.         IMPORT_CFM_FUNCTION    WideSquareRoot
  481.     ENDIF
  482.  
  483. ;
  484. ; wide *WideSubtract(wide *target, const wide *source)
  485. ;
  486.     IF ¬ GENERATINGCFM THEN
  487.         Macro
  488.         _WideSubtract
  489.             move.w    #$51,d0
  490.             dc.w     $A832
  491.         EndM
  492.     ELSE
  493.         IMPORT_CFM_FUNCTION    WideSubtract
  494.     ENDIF
  495.  
  496. ;
  497. ; wide *WideMultiply(long multiplicand, long multiplier, wide *target)
  498. ;
  499.     IF ¬ GENERATINGCFM THEN
  500.         Macro
  501.         _WideMultiply
  502.             move.w    #$52,d0
  503.             dc.w     $A832
  504.         EndM
  505.     ELSE
  506.         IMPORT_CFM_FUNCTION    WideMultiply
  507.     ENDIF
  508.  
  509. ; returns the quotient 
  510. ;
  511. ; long WideDivide(const wide *dividend, long divisor, long *remainder)
  512. ;
  513.     IF ¬ GENERATINGCFM THEN
  514.         Macro
  515.         _WideDivide
  516.             move.w    #$53,d0
  517.             dc.w     $A832
  518.         EndM
  519.     ELSE
  520.         IMPORT_CFM_FUNCTION    WideDivide
  521.     ENDIF
  522.  
  523. ; quotient replaces dividend 
  524. ;
  525. ; wide *WideWideDivide(wide *dividend, long divisor, long *remainder)
  526. ;
  527.     IF ¬ GENERATINGCFM THEN
  528.         Macro
  529.         _WideWideDivide
  530.             move.w    #$55,d0
  531.             dc.w     $A832
  532.         EndM
  533.     ELSE
  534.         IMPORT_CFM_FUNCTION    WideWideDivide
  535.     ENDIF
  536.  
  537.     ENDIF
  538. ;
  539. ; wide *VectorMultiply(long count, const long *vector1, long step1, const long *vector2, long step2, wide *dot)
  540. ;
  541.     IF ¬ GENERATINGCFM THEN
  542.         Macro
  543.         _VectorMultiply
  544.             move.w    #$54,d0
  545.             dc.w     $A832
  546.         EndM
  547.     ELSE
  548.         IMPORT_CFM_FUNCTION    VectorMultiply
  549.     ENDIF
  550.  
  551. ;
  552. ; unsigned long RandomBits(long count, long focus)
  553. ;
  554.     IF ¬ GENERATINGCFM THEN
  555.         Macro
  556.         _RandomBits
  557.             move.w    #$56,d0
  558.             dc.w     $A832
  559.         EndM
  560.     ELSE
  561.         IMPORT_CFM_FUNCTION    RandomBits
  562.     ENDIF
  563.  
  564. ;
  565. ; void SetRandomSeed(const wide *seed)
  566. ;
  567.     IF ¬ GENERATINGCFM THEN
  568.         Macro
  569.         _SetRandomSeed
  570.             move.w    #$57,d0
  571.             dc.w     $A832
  572.         EndM
  573.     ELSE
  574.         IMPORT_CFM_FUNCTION    SetRandomSeed
  575.     ENDIF
  576.  
  577. ;
  578. ; wide *GetRandomSeed(wide *seed)
  579. ;
  580.     IF ¬ GENERATINGCFM THEN
  581.         Macro
  582.         _GetRandomSeed
  583.             move.w    #$58,d0
  584.             dc.w     $A832
  585.         EndM
  586.     ELSE
  587.         IMPORT_CFM_FUNCTION    GetRandomSeed
  588.     ENDIF
  589.  
  590.     ENDIF ; __GXMATH__
  591.